
package com.google.earth.kml;

import java.util.ArrayList;
import java.util.List;

/** 
 * Schema fragment(s) for this class:
 * <pre>
 * &lt;xs:complexType xmlns:ns="http://earth.google.com/kml/2.1" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="UpdateType">
 *   &lt;xs:sequence>
 *     &lt;xs:element type="xs:string" name="targetHref" minOccurs="1"/>
 *     &lt;xs:choice maxOccurs="unbounded">
 *       &lt;!-- Reference to inner class Choice -->
 *     &lt;/xs:choice>
 *   &lt;/xs:sequence>
 * &lt;/xs:complexType>
 * </pre>
 */
public class UpdateType
{
    private String targetHref;
    private List<Choice> choiceList = new ArrayList<Choice>();

    /** 
     * Get the 'targetHref' element value.
     * 
     * @return value
     */
    public String getTargetHref() {
        return targetHref;
    }

    /** 
     * Set the 'targetHref' element value.
     * 
     * @param targetHref
     */
    public void setTargetHref(String targetHref) {
        this.targetHref = targetHref;
    }

    /** 
     * Get the list of choice items.
     * 
     * @return list
     */
    public List<Choice> getChoiceList() {
        return choiceList;
    }

    /** 
     * Set the list of choice items.
     * 
     * @param list
     */
    public void setChoiceList(List<Choice> list) {
        choiceList = list;
    }
    /** 
     * Schema fragment(s) for this class:
     * <pre>
     * &lt;xs:choice xmlns:ns="http://earth.google.com/kml/2.1" xmlns:xs="http://www.w3.org/2001/XMLSchema" maxOccurs="unbounded">
     *   &lt;xs:element type="ns:CreateType" name="Create" minOccurs="0"/>
     *   &lt;xs:element type="ns:DeleteType" name="Delete" minOccurs="0"/>
     *   &lt;xs:element type="ns:ChangeType" name="Change" minOccurs="0"/>
     *   &lt;xs:element type="ns:ReplaceType" name="Replace" minOccurs="0"/>
     * &lt;/xs:choice>
     * </pre>
     */
    public static class Choice
    {
        private int choiceListSelect = -1;
        private static final int CREATE_CHOICE = 0;
        private static final int DELETE_CHOICE = 1;
        private static final int CHANGE_CHOICE = 2;
        private static final int REPLACE_CHOICE = 3;
        private CreateType create;
        private DeleteType delete;
        private ChangeType change;
        private ReplaceType replace;

        private void setChoiceListSelect(int choice) {
            if (choiceListSelect == -1) {
                choiceListSelect = choice;
            } else if (choiceListSelect != choice) {
                throw new IllegalStateException(
                        "Need to call clearChoiceListSelect() before changing existing choice");
            }
        }

        /** 
         * Clear the choice selection.
         */
        public void clearChoiceListSelect() {
            choiceListSelect = -1;
        }

        /** 
         * Check if Create is current selection for choice.
         * 
         * @return <code>true</code> if selection, <code>false</code> if not
         */
        public boolean ifCreate() {
            return choiceListSelect == CREATE_CHOICE;
        }

        /** 
         * Get the 'Create' element value.
         * 
         * @return value
         */
        public CreateType getCreate() {
            return create;
        }

        /** 
         * Set the 'Create' element value.
         * 
         * @param create
         */
        public void setCreate(CreateType create) {
            setChoiceListSelect(CREATE_CHOICE);
            this.create = create;
        }

        /** 
         * Check if Delete is current selection for choice.
         * 
         * @return <code>true</code> if selection, <code>false</code> if not
         */
        public boolean ifDelete() {
            return choiceListSelect == DELETE_CHOICE;
        }

        /** 
         * Get the 'Delete' element value.
         * 
         * @return value
         */
        public DeleteType getDelete() {
            return delete;
        }

        /** 
         * Set the 'Delete' element value.
         * 
         * @param delete
         */
        public void setDelete(DeleteType delete) {
            setChoiceListSelect(DELETE_CHOICE);
            this.delete = delete;
        }

        /** 
         * Check if Change is current selection for choice.
         * 
         * @return <code>true</code> if selection, <code>false</code> if not
         */
        public boolean ifChange() {
            return choiceListSelect == CHANGE_CHOICE;
        }

        /** 
         * Get the 'Change' element value.
         * 
         * @return value
         */
        public ChangeType getChange() {
            return change;
        }

        /** 
         * Set the 'Change' element value.
         * 
         * @param change
         */
        public void setChange(ChangeType change) {
            setChoiceListSelect(CHANGE_CHOICE);
            this.change = change;
        }

        /** 
         * Check if Replace is current selection for choice.
         * 
         * @return <code>true</code> if selection, <code>false</code> if not
         */
        public boolean ifReplace() {
            return choiceListSelect == REPLACE_CHOICE;
        }

        /** 
         * Get the 'Replace' element value.
         * 
         * @return value
         */
        public ReplaceType getReplace() {
            return replace;
        }

        /** 
         * Set the 'Replace' element value.
         * 
         * @param replace
         */
        public void setReplace(ReplaceType replace) {
            setChoiceListSelect(REPLACE_CHOICE);
            this.replace = replace;
        }
    }
}
